package com.example.user.biz.controller;

import com.example.common.domain.Result;
import com.example.user.biz.domain.dto.UpdatePasswordDTO;
import com.example.user.biz.domain.dto.UpdateUserInfoDTO;
import com.example.user.domain.vo.UserInfoVO;
import com.example.user.biz.service.UserService;
import com.example.user.domain.vo.VolunteerVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "user接口相关")
@Slf4j
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;

    @GetMapping
    @Operation(summary = "获取用户信息")
    public Result<UserInfoVO> getUserInfo() {
        log.info("获取用户信息");
        UserInfoVO userInfoVO = userService.getUserInfo();
        return Result.success(userInfoVO);
    }
    @PutMapping
    @Operation(summary = "更新用户信息")
    public Result<String> updateUserInfo(@RequestBody @Validated UpdateUserInfoDTO updateUserInfo) {
        log.info("修改用户信息，用户信息为：{}", updateUserInfo);
        userService.updateUserInfo(updateUserInfo);
        return Result.success("修改成功");
    }
    @GetMapping("/volunteer/{userId}")
    @Operation(summary = "志愿活动需要个人信息")
    public Result<VolunteerVO> getVolunteer(@PathVariable("userId") Long userId){
        return Result.success(userService.getVolunteer(userId));
    }


}
